<?php

namespace app\index\controller;

use app\index\server\UserServer;
use app\index\validate\GetListValidate;
use app\index\validate\IDMustBePostiveInt;
use app\index\validate\UserValidate;
use app\lib\exception\DatabaseException;
use think\Exception;

class User extends Auth
{
    private $server;

    public function __construct()
    {
        $this->server = new UserServer();
    }

    public function getUserList()
    {
        // 验证 成功返回 params
        $params = (new GetListValidate())->goCheck();
        // 操作
        $result = $this->server->getList($params);
        // return
        return $result;
    }

    public function update()
    {
        $params = (new UserValidate())->goCheck();
        $result = $this->server->addOrUpdate($params);
        return $result;
    }

    public function detail($id)
    {
        (new IDMustBePostiveInt())->goCheck();
        $result = $this->server->detail($id);
        return $result;
    }

    public function changeStatus($id)
    {
        (new IDMustBePostiveInt())->goCheck();
        $result = $this->server->changeStatus($id);
        return $result;
    }
}